package com.ciaj.module.sys.controller;


import com.ciaj.base.bean.ResponseEntity;
import com.ciaj.module.sys.entity.po.SysUser;
import com.ciaj.module.sys.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 系统用户表 Gen 前端控制器
 * </p>
 *
 * @author ciaj.
 * @since 2020-08-13
 */
@RestController
@RequestMapping("api/sys/user")
@Api(value = "/api/sys/user", tags = "系统用户管理")
public class SysUserController {

    @Autowired
    ISysUserService iSysUserService;

    @GetMapping("/{id}")
    public ResponseEntity getById(@PathVariable("id") String id) {
        SysUser byId = iSysUserService.getById(id);
        return ResponseEntity.success().put(byId);
    }

    @PostMapping("/list")
    public ResponseEntity list(@ApiParam @RequestBody SysUser sysUser) {
        List<SysUser> list = iSysUserService.list();
        return ResponseEntity.success().put(list);
    }

    @PostMapping("/save")
    public ResponseEntity save(@ApiParam @RequestBody SysUser sysUser) {
        iSysUserService.save(sysUser);
        return ResponseEntity.success().put(sysUser);
    }

    @PutMapping("/update")
    public ResponseEntity update(@ApiParam  @RequestBody SysUser sysUser) {
        iSysUserService.updateById(sysUser);
        return ResponseEntity.success();
    }

    @DeleteMapping("/del/{id}")
    public ResponseEntity delById(@PathVariable("id") String id) {
        iSysUserService.removeById(id);
        return ResponseEntity.success();
    }

}
